package com.gzsxy.esjy.configuration;


import com.gzsxy.esjy.NettyDispatcher;
import com.gzsxy.esjy.configuration.listener.ApplicationCloseListener;
import com.gzsxy.esjy.configuration.listener.ApplicationStartListener;
import com.gzsxy.esjy.mapping.MappingInit;
import com.gzsxy.esjy.netty.NettyServer;
import com.gzsxy.esjy.request.ContextHolder;
import com.gzsxy.esjy.request.HttpServletRequest;
import com.gzsxy.esjy.response.HttpServletResponse;
import com.gzsxy.esjy.thread.ExcuteService;
import com.gzsxy.esjy.thread.NettyServicePool;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 配置
 * @author zhangxiaolong
 * @date 2022/7/6 9:36
 */
@Configuration
public class ServerConfiguration {

	@Bean
	public NettyDispatcher nettyDispatcher() {
		return new NettyDispatcher() ;
	}
	
	@Bean
	public ExcuteService excuteService() {
		return new ExcuteService() ;
	}
	
	@Bean
	public NettyServer nettyServer() {
		return new NettyServer() ;
	}
	
	@Bean
	public MappingInit mappingInit() {
		return new MappingInit() ;
	}
	
	@Bean
	public NettyServicePool nettyServicePool() {
		return new NettyServicePool() ;
	}
	
	/**
	 * 注册request
	 * @return
	 */
//	@Bean
//	public HttpServletRequest httpServletRequest() {
//		return ContextHolder.getContextHolderProxy(HttpServletRequest.class) ;
//	}

	
	/**
	 * 注册response
	 * @return
	 */
//	@Bean
//	public HttpServletResponse httpServletResponse() {
//		return ContextHolder.getContextHolderProxy(HttpServletResponse.class) ;
//	}
	
	@Bean
	public NettyBeanProcesser nettyBeanProcesser() {
		return new NettyBeanProcesser() ;
	}
	
	@Bean
	public ApplicationCloseListener applicationCloseListener() {
		return new ApplicationCloseListener() ;
	}
	
	@Bean
	public ApplicationStartListener applicationStartListener() {
		return new ApplicationStartListener() ;
	}
	
	@Bean
	public NettyHandlerFactory nettyHandlerFactory() {
		return new NettyHandlerFactory() ;
	}
}
